Skip to content

nix: implicitly install pm2-prom-module on startup#319

Closed
hlolli wants to merge 1 commit intomasterfrom
feature/pm2-prom-module
Closed

nix: implicitly install pm2-prom-module on startup#319
hlolli wants to merge 1 commit intomasterfrom
feature/pm2-prom-module

Conversation

@hlolli
Copy link
Copy Markdown
Contributor

@hlolli hlolli commented Mar 27, 2026

this is non-ideal solution to get pm2-prom-module, as it will run on every consumer of the nix package of ryo. But with flakification work down the line we'll be able to add options to run custom pre/post scripts on startup. As a temporary workaround to prevent unnecessary complexity on operator side, we'll install this package, which is in a way quite useful for any operator of ryo anyway as they'll gain more visibility and stats to their monitoring setups.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Nix-packaged startup wrapper for blockfrost-backend-ryo to automatically install pm2-prom-module on service start, aiming to reduce operator setup work for Prometheus/PM2 monitoring.

Changes:

  • Split the PM2 startup wrapper into separate commands (delete, install module, start).
  • Add pm2 install pm2-prom-module during startup (errors currently ignored).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +47 to 50
${nodePackages.pm2}/bin/pm2 delete all
${nodePackages.pm2}/bin/pm2 install pm2-prom-module || true
${nodePackages.pm2}/bin/pm2 start \
$out/libexec/source/dist/server.js \
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pm2 delete all will remove every PM2-managed process for the service user/PM2_HOME, including any other apps or modules an operator may be running under the same user. Safer is to name this process explicitly (e.g., via pm2 start --name) and delete only that name (or use a dedicated PM2_HOME / user that is guaranteed to be exclusive).

Suggested change
${nodePackages.pm2}/bin/pm2 delete all
${nodePackages.pm2}/bin/pm2 install pm2-prom-module || true
${nodePackages.pm2}/bin/pm2 start \
$out/libexec/source/dist/server.js \
pm2AppName="${name}"
${nodePackages.pm2}/bin/pm2 delete "$pm2AppName" || true
${nodePackages.pm2}/bin/pm2 install pm2-prom-module || true
${nodePackages.pm2}/bin/pm2 start \
$out/libexec/source/dist/server.js \
--name "$pm2AppName" \

Copilot uses AI. Check for mistakes.
${nodePackages.pm2}/bin/pm2 delete all; \
${nodePackages.pm2}/bin/pm2 start \
${nodePackages.pm2}/bin/pm2 delete all
${nodePackages.pm2}/bin/pm2 install pm2-prom-module || true
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing pm2-prom-module at runtime (pm2 install ...) makes startup depend on external network availability and an unpinned npm artifact, which hurts reproducibility and can break cold starts/offline deployments. If this is required, prefer packaging/pinning it in Nix (or at least pinning the version in the install command) and handle failures explicitly rather than swallowing them with || true (e.g., log and continue, or gate install on module not already being present).

Copilot uses AI. Check for mistakes.
@slowbackspace
Copy link
Copy Markdown
Contributor

superseded by #320

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants